﻿@{
    ViewBag.Title = "Index";
}

<!DOCTYPE html>
<html>
<head>
    <title>Comet</title>
    <script src="~/Scripts/jquery-1.4.1.js"></script>
    <script>
        $(function () {
            wait();

            $('#btn_send').click(function () {
                var msg = $('#content').val().trim();
                send(msg);
            });

            $('#btn_count').click(function () {
                send('count');
            });

            //$('#btn_send').on('click', function () {
            //    alert('send');
            //    //send();
            //});
        });

        function send(msg) {
            $.post("/Models/AsyncComet.ashx", { 'content': msg }, function (retData) {
                $('#result').append(retData + '</br>');
            }, 'html');

            
        }

        function wait() {
            $.post("/Models/AsyncComet.ashx", { 'content': 'connect' }, function (retData) {
                console.log(retData);
                $('#result').append(retData + '</br>');
                wait();
            }, 'html');
        }
    </script>
</head>
<body>
    <div id="container">
        <input id="content" />
        <input type="button" value="send" id="btn_send" />
        <input type="button" value="在线人数据查询" id="btn_count" />

        <div id="result"></div>
    </div>

</body>
</html>
